package com.imooc.diners.controller;

import com.imooc.commons.model.domain.ResultInfo;
import com.imooc.commons.utils.ResultInfoUtil;
import com.imooc.diners.service.SendVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author gcq
 * @Create 2022-10-23
 */
@RestController
public class SendVerifyCodeController {

    @Autowired
    private SendVerifyCodeService sendVerifyCodeService;

    @Autowired
    private HttpServletRequest request;

    @GetMapping("/send")
    public ResultInfo send(@RequestParam String phone) {
        sendVerifyCodeService.send(phone);
        return ResultInfoUtil.buildSuccess(request.getServletPath(),"发送成功");
    }
}